package springboot.demo.modules.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    //队列持久
    @Bean
    public Queue hello2() {
        return new Queue("query.hello2", true);
    }
    @Bean
    public Queue hello1() {
        return new Queue("query.hello1", true);
    }

    //声明交互器
    @Bean
    TopicExchange topicExchange() {
        return new TopicExchange("topicExchange");
    }

    //绑定
    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(hello1()).to(topicExchange()).with("query.hello1");
    }

    @Bean
    public Binding binding2() {
        return BindingBuilder.bind(hello2()).to(topicExchange()).with("query.#");
    }



}
